<template>
  <div id="fresh" v-if="articles.length > 0">
    <div class="adv-content">
      <p>Hello World!</p>
    </div>
    <div class="fresh">
      <div v-for="item in articles" :key="item.id" class="fresh-item">
        <div class="fresh-item-box">
          <el-image :src="item.cover" fit="fill" class="fresh-image"></el-image>
          <div class="fresh-item-div">
            <el-link :underline="false" class="title" @click="showDetail(item.id)">
              {{ item.title }}
            </el-link>
            <div class="content">
              {{ item.content }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
    articleQueryList
} from '@/api/article'

export default {
    name: 'my-fresh',
    data () {
        return {
            articles: []
        }
    },
    methods: {
        showDetail (articleId) {
            this.$router.push({
                path: 'articleDetail',
                query: {
                    'articleId': articleId
                }
            })
        }
    },
    mounted () {
        articleQueryList({
            limit: 20
        }).then((response) => {
            if (response && response.code === 200) {
                this.articles = response.data
            }
        })
    }
}
</script>

<style scoped>
/* id选择器 最外层div */
#fresh {
  width: 100%;
  height: 100%;
  margin: 5px 0px 0px 0px;
  padding: 0px;
  background-color: beige;
}

/* 横条 */
.adv-content {
  color: white;
  width: auto;
  height: 80px;
  line-height: 80px;
  text-align: center;
  font-size: 25px;
  margin: 0px;
  /* background-image: url("../assets/images/bg_rainbow.png") !important; */
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-color: #fff;
  margin: 0px 0px 0px 0px;

  background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgb(237, 183, 34)), to(rgb(16, 157, 108)));
}

/* 精品box */
.fresh {
  width: auto;
  height: auto;
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
  padding: 0px 0px 0px 0px;
  box-sizing: border-box;
  margin: 5px 0px 0px 0px;
  background-color: beige;
}

/* 遍历的每一项 */
.fresh-item {
  margin: 0px 0px 5px 0px;
  padding: 0px 0px 0px 0px;
  min-height: 250px;
  width: calc((100% - 40px) / 4);
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid #999;
  background-color: #fff;
  /* border-radius: 4px; */
}

.fresh-item-box {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
}

.fresh-item:nth-child(n+4) {
  margin-bottom: 5px;
}

/* 图片 */
.fresh-image {
  width: 100%;
  height: 180px;
  display: block;
  margin: 0 auto;
}

.fresh-item-div {
  margin: 0px 10px 0px 10px;
  padding: 5px;
}

.title {
  font-size: 14px;
  font-weight: 600;
  color: #000;
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.content {
  margin: 5px 0px 5px 0px;
  font-size: 12.8px;
  font-weight: 400;
  color: dimgray;
  line-height: 30px;
  line-height: 30px;
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* 参数 */
.fresh-item-params {
  width: auto;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  margin: 0px 30px 0px 3px;
}

.fresh-item-rate .el-rate__icon {
  margin: 0px !important;
  padding: 0px !important;
}

/* el-card */
.clearfix:before,
.clearfix:after {
  display: inline-block;
  content: "";
}

.clearfix:after {
  clear: both
}

.box-card {
  width: 100%;
}

/* 评分星星样式 */
.el-rate__icon {
  margin: 0px !important;
}
</style>
